PositionForm = Ext.extend(Ext.Window, {
	formPanel : null,
	constructor : function(a) {
		Ext.apply(this, a);
		this.initComponents();
		PositionForm.superclass.constructor.call(this, {
			id : "PositionFormWin",
			layout : "fit",
			iconCls : "menu-job",
			items : this.formPanel,
			modal : true,
			height : 200,
			width : 400,
			maximizable : true,
			title : "新增/编辑职位信息",
			buttonAlign : "center",
			buttons : this.buttons,
			keys : {
				key : Ext.EventObject.ENTER,
				fn : this.save.createCallback(this.formPanel, this),
				scope : this
			}
		});
	},
	initComponents : function() {
		this.formPanel = new Ext.FormPanel({
			id : "PositionForm",
			layout : "form",
			bodyStyle : "padding:10px 10px 10px 10px",
			border : false,
			url : __ctxPath + "/system/savePosition.do",
			defaults : {
				anchor : "98%,98%"
			},
			defaultType : "textfield",
			items : [ {
				name : "position.id",
				xtype : "hidden",
				value : this.id == null ? "" : this.id
			}, {
				xtype : "hidden",
				name : "position.parentId",
				value : this.parentId
			}, {
				fieldLabel : "职位名称",
				name : "position.positionName",
				id : "positionName",
				maxLength : 128,
				allowBlank : false,
//				regex: /^[\da-zA-Z\u4E00-\u9FA5]{1,12}$/,  
//                regexText:'不能输入特殊符号，最大长度12位！',   
				blankText : "职位名称不能为空!"
			}, {
				xtype : "textarea",
				fieldLabel : "职位职责",
				name : "position.responsibility",
				id : "positionResponsibility",
				maxLength : 512
			}, {
				xtype : "combo",
				fieldLabel:"职位状态",
				hiddenName : "position.state",
				mode : "local",
				triggerAction : "all",
				editable : false,
				store : [ [ "1", "有效" ] , [ "0", "失效" ]],
				value : '1'
			} ]
		});
		if (this.id != null && this.id != "undefined") {
			this.formPanel.loadData({
				url : __ctxPath + "/system/getPosition.do?id=" + this.id,
				preName : "position",
				root : "result",
				waitMsg : "正在载入数据...",
				success : function(a, b) {
					
				},
				failure : function(a, b) {
					Ext.ux.Toast.msg("操作提示", "对不起，数据加载失败！");
				}
			});
		}
		this.buttons = [ {
			text : "保存",
			iconCls : "btn-save",
			handler : this.save.createCallback(this.formPanel, this)
		}, {
			text : "取消",
			iconCls : "btn-cancel",
			handler : this.cancel.createCallback(this)
		} ];
	},
	cancel : function(a) {
		a.close();
	},
	save : function(a, b) {
		if (a.getForm().isValid()) {
			a.getForm().submit({
				method : "POST",
				waitMsg : "正在提交数据...",
				success : function(c, e) {
					Ext.ux.Toast.msg("操作提示", "成功保存信息！");
					var d = Ext.getCmp("staffPositionViewPositionTreePanel");
					if (d != null) {
						d.root.reload();
					}
					b.close();
				},
				failure : function(c, d) {
					Ext.MessageBox.show({
						title : "操作提示",
						msg : "信息保存出错，请联系管理员！",
						buttons : Ext.MessageBox.OK,
						icon : Ext.MessageBox.ERROR
					});
					b.close();
				}
			});
		}
	}
});